package vn.edu.hut.soict.translate.dictionary.pos;

import java.util.List;

import vn.edu.hut.soict.translate.dictionary.Dictionary;

public class POSDictionary extends Dictionary<String, String> {
	public static final String DICTIONARY_FILE = "res/dictionary/pos.txt";

	protected void addEntry(String word, String content) {
		super.addEntry(word, content);
	}

	public List<String> partOfSpeechs(String word) {
		return lookUp(word);
	}

	public boolean isContentWord(String word) {
		List<String> posList = partOfSpeechs(word);
		if (posList != null) {
			for (String pos : posList) {
				char type = pos.charAt(0);
				if (type == 'A' || type == 'N' || type == 'P' || type == 'V' || type == 'I') {
					return true;
				}
			}
		}
		return false;
	}

	public boolean samePartOfSpeech(String word1, String word2) {
		List<String> posList1 = partOfSpeechs(word1);
		List<String> posList2 = partOfSpeechs(word2);
		if (posList1 != null && posList2 != null) {
			for (String pos1 : posList1) {
				for (String pos2 : posList2) {
					if (pos1.equals(pos2)) {
						return true;
					}
				}
			}
		}
		else {
			if (posList1 == null) {
				System.err.println("Words not found in dictionary: " + word1);
			}
			if (posList2 == null) {
				System.err.println("Words not found in dictionary: " + word2);
			}
		}
		return false;
	}
}
